package com.green.aop.advice;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

@Aspect
//@Component
public class TimeLongAdvice {

    @Around("execution(* com.green.aop.service.IUserService.*(..))")
    public Object getTimeLong(ProceedingJoinPoint joinPoint) {
        long startTime = System.currentTimeMillis();

        Object result = null;
        try {
            result = joinPoint.proceed();
            System.out.println("方法返回值=====>" + result);
        } catch (Throwable e) {
            throw new RuntimeException(e);
        }
        long endTime = System.currentTimeMillis();
        System.out.println("总耗时===>" + (endTime - startTime));
        return result;
    }
}
